
class Collection {

  static Map<PROPERTY, List<OBJECT>> groupSimpleObjects<PROPERTY, OBJECT>(List<OBJECT> list, PROPERTY getProperty(OBJECT obj)){
    var keys = List<PROPERTY>();

    for (var item in list){
      var prop = getProperty(item);
      if (!keys.any((i) => i == prop)){
        keys.add(prop);
      }
    }

    var groups = Map<PROPERTY, List<OBJECT>>();
    for (var key in keys){
      groups[key] = list.where((i) => getProperty(i) == key).toList();
    }
    return groups;
  }

//  static addIfNotNull<OBJECT>(){
//    var condition = true;
//
//  }

}
